import {View, ScrollView, Text, Image} from '@tarojs/components';
import Taro from '@tarojs/taro';
import React, {Component} from 'react';
import * as T from '../types';
import './index.less';
import actions from '../actions/index';
import {connect} from 'react-redux';
import {store2Props} from '../selectors';
import moment from 'dayjs';
import {_, WMkit, wxAuth} from 'wmkit';
import Blank from '@/pages/common/blank';
import {debounce, throttle} from 'lodash';
import {cache} from 'config';

import EmptyImg from '@/assets/image/none/Empty.png';

const flowStatus = (status) => {
  if (status == 0) {
    return '签到';
  } else if (status == 1) {
    return '注册';
  } else if (status == 2) {
    return '分享商品';
  } else if (status == 3) {
    return '分享注册';
  } else if (status == 4) {
    return '分享购买';
  } else if (status == 5) {
    return '评论商品';
  } else if (status == 6) {
    return '晒单';
  } else if (status == 7) {
    return '完善个人信息';
  } else if (status == 8) {
    return '绑定微信';
  } else if (status == 9) {
    return '添加收货地址';
  } else if (status == 10) {
    return '关注店铺';
  } else if (status == 11) {
    return '订单完成';
  } else if (status == 12) {
    return '订单抵扣';
  } else if (status == 13) {
    return '优惠券兑换';
  } else if (status == 14) {
    return '积分兑换';
  } else if (status == 15) {
    return '退单返还';
  } else if (status == 16) {
    return '订单取消返还';
  } else if (status == 17) {
    return '过期扣除';
  } else if (status == 18) {
    return '会员导入增加积分';
  } else if (status == 19) {
    return '权益发放';
  } else if (status == 20) {
    return '首单积分';
  } else if (status == 21) {
    return '满返积分';
  } else if (status == 22) {
    return '编辑会员信息修改积分';
  } else if (status == 23) {
    return '礼包领取';
  } else if (status == 24) {
    return '任务完成';
  } else if (status == 25) {
    return '抽奖';
  } else if (status == 26) {
    return '白鲸鱼二手回收';
  } else if (status == 28) {
    return '蚂蚁星球电影票订单';
  } else {
    return '';
  }
};

type IPointRecordExpendProps = T.IProps & T.IPointRecordExpendProps;
//@ts-ignore
@connect<Partial<IPointRecordExpendProps>, T.IPointRecordExpendState>(store2Props, actions)
export default class Info extends Component<Partial<IPointRecordExpendProps>, T.IPointRecordExpendState> {
  constructor(props: IPointRecordExpendProps) {
    super(props);
  }

  render() {
    let {dataList, pageNum, totalPages} = this.props;
    return (
      <View>
        {dataList.map((item, index) => (
          <View className="item">
            <View>
              <Text className="title">{flowStatus(item.serviceType)}</Text>
              <Text className="time">{moment(item.opTime).format('YYYY-MM-DD')}</Text>
            </View>
            <View className="pointBox">
              <Text className="pointAddicon">-</Text>
              <Text className="point">{item.points}</Text>
            </View>
          </View>
        ))}
        {dataList.length != 0 && pageNum + 1 != totalPages && <View className="status">加载中</View>}
        {dataList.length != 0 && pageNum + 1 == totalPages && <View className="status">仅展示最近6个月的支出明细</View>}
        {dataList.length == 0 && (
          <Blank
            content="暂无积分支出记录~"
            img={EmptyImg}
            imgStyle={{width: '400rpx', height: '400rpx'}}
            textStyle={{
              fontSize: '32rpx',
              color: '#999999',
              textAlign: 'center',
              marginTop: '40rpx',
            }}
          />
        )}
      </View>
    );
  }
}

//create by moon https://github.com/creasy2010/moon
